LD

Section: User Commands (1)
Updated: 17 July 1986
Index Return to Main Contents
 

NAME

ld - link editor  

SYNOPSIS

ld [ -align datum ] [ -A name ] [ -d ] [ -D hex ]
      [ -e entry ] [ -lx ] [ -Ldir ] [ -M ] [ -n ]
      [ -N ] [ -o name ] [ -r ] [ -s ] [ -S ] [ -t ]
      [ -T[text]hex ] [ -Tdata hex ] [ -u name ]
      [ -x ] [ -X ] [ -ysym ] [ -z ] filename...  

DESCRIPTION

ld combines several object programs into one, resolves external references, and searches libraries. In the simplest case several object filenames are given, and ld combines them, producing an object module which can either be executed or become the input for a subsequent ld run. In the latter case, the -r option must be given to preserve the relocation bits. The output of ld is left on a file called a.out if not otherwise specified. The output file is made executable only if no errors occurred during link editing.

Files specified by the argument filename ... are concatenated in the order specified. The entry point of the output is the beginning of the first routine, unless the -e option is specified.

If a named file is a library, it is searched exactly once at the point it is encountered in the argument list. Only those routines defining an unresolved external reference are loaded. If a routine from a library references another routine in the same library, and the library has not been processed by ranlib, the referenced routine must appear after the referencing routine in the library. Thus the order of programs within libraries may be important. The first member of a library should be a file named `__.SYMDEF', which is understood to be a dictionary for the library as produced by ranlib; the dictionary is searched iteratively to satisfy as many references as possible.

The symbols _etext, _edata and _end (etext, edata and end in C) are reserved, and if referred to, are set to the first location above the program, the first location above initialized data, and the first location above all data, respectively. It is erroneous to define these symbols.  

OPTIONS

Options should appear before the filenames, except abbreviated library names specified by the -l option, which can appear anywhere.
-align datum
datum (usually a FORTRAN common block) is increased in length to be a multiple of the page size; its beginning is set at a page boundary.
-A name
Incremental loading: linking is to be done in a manner so that the resulting object may be read into an already executing program. name is the name of a file whose symbol table is taken as a basis on which to define additional symbols. Only newly linked material is entered into the text and data portions of a.out, but the new symbol table will reflect all symbols defined before and after the incremental load. This argument must appear before any other object file in the argument list. One or both of the -T options may be used as well, and will be taken to mean that the newly linked segment will commence at the corresponding addresses (which must be a multiple of the page size). The default value is the old value of _end.
-d
Force definition of common storage even if the -r flag is present.
-D hex
Pad the data segment with zero-valued bytes to make it hex bytes long.
-e entry
Define the entry point: the entry argument is made the name of the entry point of the loaded program.
-lx
This option is an abbreviation for the library name libx.a, where x is a string. ld searches for libraries first in any directories specified with -L options, then in the standard directory /sprite/lib/tm.md, where tm is the target machine on which the linked program is intended to execute. Tm defaults to the value of the MACHINE environment variable, but may be overridden with the -m switch. A library is searched when its name is encountered, so the placement of a -l is significant.
-Ldir
Add dir to the list of directories in which libraries are searched for. Directories specified with -L are searched before the standard directory.
-mtm
Use tm as the target machine for this link, rather than the MACHINE environment variable. This switch determines where the linker looks for libraries (see the -l switch above).
-M
Produce a primitive load map, listing the names of the files which will be loaded.
-n
Arrange (by giving the output file a 0410 `magic number') that when the output file is executed, the text portion will be read-only and shared among all processes executing the file. This involves moving the data areas up to the first possible segment boundary following the end of the text.
-N
Do not make the text portion read-only or sharable. (Use `magic number' 0407.)
-o name
Name is made the name of the ld output file, instead of a.out.
-r
Generate relocation bits in the output file so that it can be the subject of another ld run. This flag also prevents final definitions from being given to common symbols, and suppresses the `undefined symbol' diagnostics.
-s
Strip the output, that is, remove the symbol table and relocation bits to save space (but impair the usefulness of the debuggers). This information can also be removed by strip(1).
-S
Strip the output by removing all symbols except locals and globals.
-t
Trace: display the name of each file as it is processed.
-T[text]hex
Start the text segment at location hex. Specifying -T is the same as using the -Ttext option.
-Tdata hex
Start the data segment at location hex. This option is only of use to programmers wishing to write code for PROMs, since the resulting code cannot be executed by the UNIX system.
-u name
Enter name as an undefined symbol. This is useful for loading wholly from a library, since initially the symbol table is empty and an unresolved reference is needed to force the loading of the first routine.
-x
Preserve only global (non-.globl) symbols in the output symbol table; only enter external symbols. This option saves some space in the output file.
-X
Record local symbols, except for those whose names begin with `L'. This option is used by cc to discard internally generated labels while retaining symbols local to routines.
-ysym
Display each file in which sym appears, its type and whether the file defines or references it. Many such options may be given to trace many symbols. It is usually necessary to begin sym with an `_', as external C, FORTRAN and Pascal variables begin with underscores.
-z
Arrange for the process to be loaded on demand from the resulting executable file (0413 `magic number') rather than preloaded. This is the default. Results in a (32-byte) header on the output file followed by text and data segments, each of which has a multiple of page-size bytes (being padded out with nulls in the file if necessary). With this format the first few BSS segment symbols may actually end up in the data segment; this is to avoid wasting the space resulting from rounding the data segment size. The text is read-only and shared among all processes executing the file.
 

FILES

/lib/lib*.a            libraries

/usr/lib/lib*.a       more libraries

/usr/local/lib/lib*.a still more libraries

a.out                 output file
 

SEE ALSO

as(1), ar(1), cc(1V), ranlib(1), strip(1)


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 22:49:55 GMT, December 11, 2024